package com.iodemo;

import org.apache.commons.io.IOUtils;

import java.io.*;
import java.util.Scanner;

public class PasswordTest {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入用户名");
        String name = scanner.nextLine();
        System.out.println("输入密码");
        String password = scanner.nextLine();

        OutputStream os = null;
        OutputStreamWriter osw = null;
        BufferedWriter bw = null;

        try {
            os = new FileOutputStream("/Users/edy/Desktop/file/password.txt",true);
            osw = new OutputStreamWriter(os,"UTF-8");
            bw = new BufferedWriter(osw);

            bw.write(name + "=" + password);
            bw.newLine();
            bw.flush();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            IOUtils.closeQuietly(bw);
            IOUtils.closeQuietly(osw);
            IOUtils.closeQuietly(os);
        }



    }
}
